import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { ApplyForm, ApplyQuery, ApplyVO } from "@/api/fill/apply/types";

/**
 * 查询预算申请列表
 * @param query
 * @returns
 */

export const listApply = (query?: ApplyQuery) => {
  return request({
    url: "/fill/apply/list",
    method: "post",
    data: query
  });
};

/**
 * 查询预算申请详细
 * @param id
 */
export const getApply = (id: string | number): AxiosPromise<ApplyVO> => {
  return request({
    url: "/fill/apply/" + id,
    method: "get"
  });
};

/**
 * 新增预算申请
 * @param data
 */
export const addApply = (data: ApplyForm) => {
  return request({
    url: "/fill/apply",
    method: "post",
    data: data
  });
};

/**
 * 修改预算申请
 * @param data
 */
export const updateApply = (data: ApplyForm) => {
  return request({
    url: "/fill/apply",
    method: "put",
    data: data
  });
};

/**
 * 删除预算申请
 * @param id
 */
export const delApply = (id: string | number | Array<string | number>) => {
  return request({
    url: "/fill/apply/" + id,
    method: "delete"
  });
};


//上传文件
export const uploadApplyFile = (data?: any) => {
  return request({
    url: "/fill/apply/uploadFile",
    method: "post",
    data: data
  });
};
//删除文件
export const deleteFile = (ossId?: any) => {
  return request({
    url: "/fill/apply/deleteFile/" + ossId,
    method: "get",
    params: ossId
  });
};

//获得当前登录人的部门详情
export const getUser = () => {
  return request({
    url: "/fill/apply/getUser",
    method: "post"
  });
};
